package com.hao.tool.web.component.interceptor;

import com.hao.tool.web.module.rbac.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by haol on 2017/3/15.
 */
@Configuration
public class InterceptorConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    private ManagerService managerService;

    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration inter_login = registry.addInterceptor(
                new WebLoginInterceptor(managerService));
        inter_login.addPathPatterns("/rest/**/add");
        inter_login.addPathPatterns("/rest/computer/list");
        inter_login.addPathPatterns("/rest/application/list");

        InterceptorRegistration inter_web = registry.addInterceptor(new WebInterceptor(managerService));
        inter_web.addPathPatterns("/rest/**");
        inter_web.excludePathPatterns("/rest/user/**");


    }
}
